
class P10800_39643 {

	public static void main(String[] args) {
		
		int cases = Integer.parseInt(readLn());
		
		for (int k = 0; k < cases; k++) {
			System.out.println("Case #" + (k + 1) + ":");
			process(readLn());
			
		}
		
	}
	
    private static void process(String string) {
		
    	char[][] graph = new char[200][200];
    	
    	int y = 100;
    	
    	int maxY = Integer.MIN_VALUE;
    	int minY = Integer.MAX_VALUE;
    	
    	for (int x = 0; x < string.length(); x++) {
    		switch (string.charAt(x)) {
    		
    			case 'R':
    				graph[y][x] = '/';
    				
    				if (x + 1 < string.length() && string.charAt(x+1) == 'F') y--;
    				
    				y++;
    				break;
    			case 'C':
    				graph[y][x] = '_';
    				
    				if (x + 1 < string.length() && string.charAt(x+1) == 'F') y--;
//    				if (x + 1 < string.length() && string.charAt(x+1) == 'R') y++;
    				
    				break;
    			case 'F':
    				graph[y][x] = '\\';
    				if (x + 1 < string.length() && string.charAt(x+1) == 'C') y++;
    				if (x + 1 < string.length() && string.charAt(x+1) == 'R') y++;
    				y--;
    				break;
    		}
    		
    		if (maxY < y) maxY = y;
    		if (minY > y) minY = y;
    		
    	}
		
//    	boolean strokeExists = false;
//    	for (int x = 0; x < string.length(); x++) {
//    		switch (graph[maxY][x]) {
//    		
//			case '/':
//			case '_':
//			case '\\':
//				strokeExists = true;
//    		}
//    	}
//    	
//    	if (!strokeExists) maxY--;
//    	
//    	
//    	strokeExists = false;
//    	for (int x = 0; x < string.length(); x++) {
//    		switch (graph[minY][x]) {
//    		
//			case '/':
//			case '_':
//			case '\\':
//				strokeExists = true;
//    		}
//    	}
//    	
//    	if (!strokeExists) minY++;
    	
    	
    	
    	for (y = 200-1; y >= 0; y--) {
    		StringBuffer sb = new StringBuffer("| ");
    		
    		for (int x = 0; x < string.length(); x++) {
    			switch (graph[y][x]) {
        		
	    			case '/':
	    			case '_':
	    			case '\\':
	    				sb.append(graph[y][x]);
	    				break;
	    			default : sb.append(' ');
	    			
        		}	
    		}
    		
    		String s = sb.toString().trim();
    		
    		if (s.length() > 2) {
    			System.out.println(s);
    		}
    		
    	}
    	
    	StringBuffer sb = new StringBuffer("+-");
    	
    	for (int x = 0; x < string.length() + 1; x++) {
    		sb.append('-');
    	}
    	
    	System.out.println(sb.toString().trim());
    	
    	System.out.println();
    	
	}

	static String readLn() {
        String newLine = System.getProperty("line.separator");
        StringBuffer buffer = new StringBuffer();
        int car = -1;
        try {
            car = System.in.read();
            while ((car > 0) && (car != newLine.charAt(0))) {
                buffer.append((char)car);
                car = System.in.read();
            }
            if (car == newLine.charAt(0))
            System.in.skip(newLine.length() - 1);
        } catch (java.io.IOException e) { return (null);}
        if ((car < 0) && (buffer.length() == 0)) return (null);
        return (buffer.toString()).trim();
    }
	
}
